module RailsNavigationHelper
  def matches_page?(conditions)
    RailsNavigation::Matcher.match_multiple_with_or?(controller_name, action_name, params, conditions)
  end

  def nav_to(name, path, conditions = nil, html_options = {})
    active_class = []
    active_class = ['active'] if matches_page?(conditions)

    if html_options[:class]
      custom_classes = *html_options[:class]
      classes = active_class + custom_classes
    else
      classes = active_class
    end

    html_options[:class] = classes
    content_tag(:li, link_to(name, path), html_options)
  end
end
